<template>
  <div id="d1" style="margin: auto; width: 30%">
    <div><h3 style="text-align: center">完善个人信息</h3></div>
    <el-form :model="form" ref="registForm" label-width="100px" class="demo-ruleForm">
      <el-form-item  label="账户" :label-width="formLabelWidth">
        <el-input v-model="form.uAccount" autocomplete="off" readOnly></el-input>
      </el-form-item>
      <el-form-item label="密码" :label-width="formLabelWidth">
        <el-input v-model="form.uPassword" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="昵称" :label-width="formLabelWidth">
        <el-input v-model="form.uNickname" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="真实姓名" :label-width="formLabelWidth">
        <el-input v-model="form.uName" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="身份证号" :label-width="formLabelWidth">
        <el-input v-model="form.uCardid" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="手机号" :label-width="formLabelWidth">
        <el-input v-model="form.uTel" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="邮箱" :label-width="formLabelWidth">
        <el-input v-model="form.uEmail" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="地址" :label-width="formLabelWidth">
        <el-input v-model="form.uAddress" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="余额" :label-width="formLabelWidth">
        <el-input v-model="form.uBalance" autocomplete="off" readOnly></el-input>
      </el-form-item>
      <el-form-item label="积分" :label-width="formLabelWidth">
        <el-input v-model="form.uIntegral" autocomplete="off" readOnly></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="update">提交</el-button>
        <el-button type="primary" @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
    data(){
        return {
            form:{
                uAccount:"",
                uPassword:"",
                uNickname:"",
                uName:"",
                uCardid:"",
                uTel:"",
                uEmail:"",
                uAddress:"",
                uBalance:"",
                uIntegral:""
            },
            formLabelWidth :"80px"   
              
        };
    },
    methods:{
        update(){
        this.$axios.post("/user/update",this.form)
        .then((resp)=>{
            if(resp.data.code==200){
                this.$message.success("修改成功！");
            }else{
                this.$message.error("修改失败！");
            }
        });
      },
        resetForm() {
            this.form={}
      }  
    },
    mounted(){
        this.form=JSON.parse(sessionStorage.getItem("u"));
    }
};
</script>

<style>

</style>